]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/bluetooth: Only show when rfkill is available
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 30 Aug 2023 21:56:30 +0000 (23:56 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 1 Sep 2023 11:37:04 +0000 (11:37 +0000)
We currently show the bluetooth toggle when Bluetooth can be
toggled via rfkill, or when there is a powered adapter.

While the latter condition is obvious - if there is a working
Bluetooth adapter, then Bluetooth is available - it does impose
a problem: We rely on rfkill for turning Bluetooth off, so if
rfkill is missing, the toggle is stuck.

We could handle that case and power off the adapter ourselves
when necessary, but then the toggle would just disappear when
turned off.

Instead, only show the toggle when rfkill is available, so we
can assume that turning Bluetooth on and off will work.

This is also consistent with Settings, which shows Bluetooth
as unavailable in this case.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2815>

js/ui/status/bluetooth.js

index d398f717f8cbdbb81890e0898376ea250bf8d861..1584e04683ceae40ace1acd839c5ee2ab11bc446 100644 (file)
@@ -47,7 +47,6 @@ const BtClient = GObject.registerClass({
         this._client = new GnomeBluetooth.Client();
         this._client.connect('notify::default-adapter-powered', () => {
             this.notify('active');
-            this.notify('available');
         });
         this._client.connect('notify::default-adapter-state',
             () => this.notify('adapter-state'));
@@ -59,7 +58,6 @@ const BtClient = GObject.registerClass({
             this.emit('devices-changed');
 
             this.notify('active');
-            this.notify('available');
         });
 
         this._proxy = new Gio.DBusProxy({
@@ -101,9 +99,8 @@ const BtClient = GObject.registerClass({
     get available() {
         // If we have an rfkill switch, make sure it's not a hardware
         // one as we can't get out of it in software
-        return this._proxy.BluetoothHasAirplaneMode
-            ? !this._proxy.BluetoothHardwareAirplaneMode
-            : this.active;
+        return this._proxy.BluetoothHasAirplaneMode &&
+            !this._proxy.BluetoothHardwareAirplaneMode;
     }
 
     get active() {